<?php
/*
<channel>
  <link>http://maps.google.com</link>
  <title>จุดร้องขอความช่วยเหลือ</title>
  <description><![CDATA[xxxx]]></description>
  <item>
    <guid isPermaLink="false">000493180bec6f93e23ea</guid>
    <pubDate>Thu, 21 Oct 2010 03:23:15 +0000</pubDate>

    <title>zzzzz</title>
    <description><![CDATA[<div dir="ltr">2010-10-20 18.43  yyyyy </div>]]></description>
    <author></author>
    <georss:point>
      15.066819 100.848999
    </georss:point>
    <georss:elev>0.000000</georss:elev>
  </item>
</channel>



<markers> 

  <marker lat="7.88648" lng="98.29039"
     html='&lt;b&gt;  แอบโซลูท ซีเพิร์ล บีช  รีสอร์ท Absolute Seapearl Beach Resort   &lt;/b&gt;  &lt;br&gt;  '
     label="แอบโซลูท ซีเพิร์ล บีช  รีสอร์ท Absolute Seapearl Beach Resort"
   /> 
   
   
  <marker lat="7.89488" lng="98.2991"
     html='&lt;b&gt;  200 ปี เกสต์เฮ้าส์    &lt;/b&gt;  &lt;br&gt;  '
     label="200 ปี เกสต์เฮ้าส์"
   /> 
</markers>
*/



  class ReaderXML{
    private $xml;
//      private $test;
    
    function ReaderXML($xml){
      $this->xml = $xml;
    }

    public function getReadHotelXML(){
      $xmlDoc = new DOMDocument();
      $xmlDoc->load($this->xml);


      //get elements from "<channel>"
      $markers=$xmlDoc->getElementsByTagName('markers')->item(0);
      $marker_lat = $markers->getElementsByTagName("marker").getAttribute("lat");
      $marker_lng = $markers->getElementsByTagName("marker").getAttribute("lng");
      $marker_htmlt = $markers->getElementsByTagName("marker").getAttribute("html");
      $marker_label = $markers->getElementsByTagName("marker").getAttribute("lat");

   var_dump($markers);
        echo "Label : ".$item_title."<br>";
        echo "HTML : ".$item_desc."<br>";
        echo "latitude : ".$marker_lat."<br>";
        echo "lontitude : ".$marker_lng."<br>";
        echo "##########################################<br>";
      /*
      //output elements from "<channel>"
      echo("<p><a href='" . $channel_link
        . "'>" . $channel_title . "</a>");
      echo("<br />");
      echo($channel_desc . "</p>");
      */

    $x=$xmlDoc->getElementsByTagName('item');
    $i=0;
    /*
    foreach ($xmlDoc->getElementsByTagNameNS('http://www.georss.org/georss', 'point') as $element) {
        $item_title=$x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
        $item_desc=$x->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
        $item_aut=$x->item($i)->getElementsByTagName('author')->item(0)->childNodes->item(0)->nodeValue;
        $item_date=$x->item($i)->getElementsByTagName('pubDate')->item(0)->childNodes->item(0)->nodeValue;
        $item_lat_lon =$element->nodeValue;
        $expladLatLon = explode(" ", trim($item_lat_lon));
        $lat = $expladLatLon[0];
        $lon = $expladLatLon[1];
/*
        echo "Title : ".$item_title."<br>";
        echo "Description : ".$item_desc."<br>";
        echo "latitude : ".$lat."<br>";
        echo "lontitude : ".$lon."<br>";
        echo "##########################################<br>";
        $i++;
*//*
        $result['layer'][$i]['title'] = $item_title;
        $result['layer'][$i]['description'] = "";
        $result['layer'][$i]['icon'] = "water.png";
        $result['layer'][$i]['detail'] = $item_desc;
        $result['layer'][$i]['latitude'] = $lat;
        $result['layer'][$i]['longitude'] = $lon;
        $i++;
      }
      */
        return $result;
    
    }
  }
?>

